home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / winhid10 / winhide.bas < prev    next >
Encoding:
BASIC Source File  |  1995-05-09  |  1.5 KB  |  42 lines

  1. 'Windows API calls
  2. Declare Function FindWindow% Lib "USER" (ByVal lpClassName&, ByVal lpWindowName$)
  3. Declare Function ShowWindow% Lib "USER" (ByVal hWnd%, ByVal nCmdShow%)
  4.  
  5. Sub Main ()
  6.  
  7. Dim Handle%, Class&, Title$, Nul%, HideShow%
  8.  
  9. Class = 0          'window Class to find; 0 for any
  10. HideOrShow = 0     '0 to hide, 5 to show
  11. Title = Command$   'retrieve the command line
  12.  
  13. 'check to see if the SHOW parameter was passed
  14. If UCase$(Left$(Title, 5)) = "/SHOW" Then
  15.     ' show window instead of hiding it
  16.     HideOrShow = 5
  17.     'remove the SHOW parameter from the Title variable
  18.     Title = Trim$(Right$(Title, Len(Title) - 5))
  19. End If
  20.  
  21. If Title = "" Then  'the user did not pass a Title parameter
  22.     MsgBox "You must pass the Title Text of the window you would like to hide or unhide.  For example:" + Chr$(13) + Chr$(13) + "WINHIDE Program Manager" + Chr$(13) + Chr$(13) + "will hide the Program Manager.  To unhide it, run WINHIDE like this:" + Chr$(13) + Chr$(13) + "WINHIDE /SHOW Program Manager", 64
  23. Else
  24.     'get the handle of the window with the matching title text
  25.     Handle = FindWindow(Class, Title)
  26.     
  27.     '"Handle" is True if a window was found
  28.     If Handle Then
  29.         'show or hide the window
  30.         Nul = ShowWindow(Handle, HideOrShow)
  31.     Else
  32.         'display a message if the window was not found
  33.         MsgBox "Unable to locate and " + Switch(HideOrShow = 0, "hide", HideOrShow = 5, "show") + " the window:" + Chr$(13) + Chr$(13) + Title, 48
  34.     End If
  35.  
  36. End If
  37.  
  38. End
  39.  
  40. End Sub
  41.  
  42.